package com.hualan.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.mapper.ConsultantLevelMapper;
import com.hualan.pojo.ConsultantLevel;
import com.hualan.service.ConsultantLevelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ConsultantLevelImpl implements ConsultantLevelService {
    @Autowired
    private ConsultantLevelMapper consultantLevelMapper;
    @Override
    public PageInfo<ConsultantLevel> selectLevel(Integer pageNum, Integer pageSize, String levelName) {
        PageHelper.startPage(pageNum,pageSize);
        List<ConsultantLevel> consultantLevels = consultantLevelMapper.selectLevel(levelName);
        return new PageInfo<>(consultantLevels);
    }

    @Override
    public int deleteLevel(Long id) {
        return consultantLevelMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int deleteBatch(List<Integer> ids) {
        return consultantLevelMapper.deleteBatch(ids);
    }

    @Override
    public int insertLevel(ConsultantLevel record) {
        return consultantLevelMapper.insert(record);
    }

    @Override
    public int updateLevel(Integer id, String levelName) {
        return consultantLevelMapper.updateByPrimaryKey(id, levelName);
    }
    @Override
    public List<ConsultantLevel> find() {
        return consultantLevelMapper.findAll();
    }
}
